import logging

from redis import StrictRedis

class MyConfig(object):
    DEBUG = True
    SECRET_KEY = 'dfjadfna.ldjank'
    # 数据库配置
    SQLALCHEMY_DATABASE_URI = "mysql+pymysql://root:123456@127.0.0.1:3306/information17"
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True   # 当会话结束的时候会自动提交

    # redis配置
    REDIS_HOST = '127.0.0.1'
    REDIS_PORT = 6379

    # session配置
    SESSION_TYPE = "redis"
    SESSION_USE_SIGNER = True
    SESSION_REDIS = StrictRedis(host=REDIS_HOST,port=REDIS_PORT)

    # 设置日志级别
    LEVEL_NAME = logging.DEBUG
# 开发阶段配置
class DevelopConfig(MyConfig):
    pass
# 生产环境配置
class ProductConfig(MyConfig):
    DEBUG = False
    LEVEL_NAME = logging.ERROR
# 测试阶段配置
class TestConfig(MyConfig):
    TESTING = True

# 提供配置信息访问入口
config_dict = {
    "develop":DevelopConfig,
    "product":ProductConfig,
    "test":TestConfig
}